package Q2;

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 * JPA 配置
 *
 * @author chisheng
 * @since 2021-10-25
 */
public class JpaConfig {

    /**
     * 持久单元的实体管理器工厂
     */
    private final static EntityManagerFactory FACTORY;

    static {
        /* 持久单元的实体管理器工厂的静态初始化 */
        /* 通过 persistenceUnitName 创建持久单元的实体管理器工厂 */
        FACTORY = Persistence.createEntityManagerFactory("studentUnit");
    }

    /**
     * 获取持久单元的实体管理器工厂实例
     *
     * @return 持久单元的实体管理器工厂实例
     */
    public static EntityManagerFactory getEntityManagerFactory() {
        return FACTORY;
    }

}
